﻿<%@ Page Title="" Language="C#" MasterPageFile="../Shared/Product.Master" Inherits="System.Web.Mvc.ViewPage<ProductViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <div class="classify_title">
        <strong>
            <%=Model.ProductView.ProductName %>
            <%=string.IsNullOrEmpty(Model.ProductView.SubName) ? string.Empty : string.Format("| {0}", Model.ProductView.SubName)%></strong>
    </div>
    <div class="product_memo">
        <div class="product_images">
            <div class="cover showNone">
                <a title="click zoom image" href="">
                    <img src="" alt="" /></a>
            </div>
        </div>
        <div class="desc">
            <ul>
                <li><span>品 牌 名 称:</span><%=Model.ProductView.BrandName %></li>
                <li><span>商 品 编 号：</span><%=Model.ProductView.ProductNo%></li>
                <li><span>品 牌 价 格：</span><span class="colorBlue font16 fontBold">￥<%=Model.ProductView.Price%></span></li>
                <li><span>代 理 优 惠:</span>
                    <% if (User.Identity.IsAuthenticated)
                       {
                    %>
                    <strong class="font16 colorOrange">￥<%=(Model.ProductView.Price * (decimal)Model.ProductView.MyDisCount).ToString("0.00")%></strong>
                    <span class="colorBlue">
                        <%= (ViewData["User"] as UserEntity).LevelName%></span>
                    <%
                       }
                       else
                       {
                    %>
                    <%= Html.ActionLink(ViewsResources.Shared.Login, "Login", "Home", new { returnUrl=Request.RawUrl },null)%>
                    <%
                       } 
                    %>
                    <%= Html.ActionLink("会员体系", "Archive", "News", new { eTag = "Discount" }, new { title = "会员体系" })%>
                </li>
                <li><span>折 扣 比 率：</span>
                    <% if (User.Identity.IsAuthenticated)
                       {  
                    %>
                    <strong class="font14">
                        <%=Model.ProductView.MyDisCount.ToString("0.00")%></strong><%  
                      
                       }
                       else
                       { 
                        %>
                    <% = Html.ActionLink(ViewsResources.Shared.Register,"Register","Home")%>
                    <span class="colorRed">
                        <%= ViewsResources.Shared.Enjoy3 %></span>
                    <%

                       } 
                    %>
                </li>
                <li><span>库 存 情 况：</span><em class="colorRed"><%=Model.ProductView.StockCount > 0 ? "有货" : "暂时无货" %></em></li>
            </ul>
            <div id="divAlbum" class="showNone">
                <% foreach (var item in Model.ImageList)
                   { %>
                <img src="<%=Url.Action("Thumb", "Home",
                         new { h = 430, w = 350, s = string.Format("{0}/{1}/{2}",Model.ImageRoot,item.ProductId ,item.ImageName) })%>"
                    alt="<%=item.Title %>" data-path="<%=Url.Content(string.Format("~/{0}/{1}/{2}", Model.ImageRoot, item.ProductId, item.ImageName)) %>" />
                <% } %>
            </div>
        </div>
        <div class="car">
            <% foreach (var item in Model.OptionalList.GroupBy(i => i.ExtendKey))
               { %>
            <dl class="sameProduct">
                <dt>
                    <%= string.Format("<span>{0}</span>：", item.Key)%>
                </dt>
                <dd>
                    <% foreach (var innerItem in item)
                       { %>
                    <a href="javascript:void(0)" accesskey="<%=innerItem.ExtendId %>">
                        <%=innerItem.ExtendValue %></a>
                    <% } %>
                </dd>
            </dl>
            <% } %>
            <%
                if (Model.ProductView.StockCount > 0)
                {
            %>
            <%= ViewsResources.Shared.BuyQuantity %>:
            <input type="text" name="quantity" value="1" class="width50" />
            <span onclick="return AddToCar('<%=Model.ProductView.ProductId %>');" style="cursor: pointer;">
                <img src="<%=Url.Content(ViewsResources.Shared.AddToCar) %>" alt="" />
            </span>
            <%
                }
                
            %>
        </div>
    </div>
    <div class="content" style="line-height: 2.5em;">
        <div class="t">
            ITEM DESCRIPTION</div>
        <%=Model.Details.Description %>
    </div>
    <div class="content" style="background-color: White;">
        <% Html.RenderPartial("Message", Model.GuestBook); %>
    </div>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
    <%= HtmlMetaHelper.HtmlTitle(Model.ProductView.ProductName,Model.ProductView.KeyWords,Model.ProductView.Description) %>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="cssLink" runat="server">
    <link href="<%=Url.Content("~/css/Common/jquery.ScrollImage.css") %>" rel="stylesheet"
        type="text/css" />
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="jsLink" runat="server">
    <script src="<%=Url.Content("~/Scripts/Common/jquery.ScrollImage.js") %>" type="text/javascript"></script>
    <script src="<%=Url.Content("~/Scripts/Website/AddToCar.js") %>" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="cssContent" runat="server">
    <style type="text/css">
        .product_memo
        {
            overflow: hidden;
            position: relative;
            height: 455px;
        }
        .content
        {
            line-height: 1.5em;
            font-size: 11px;
            padding: 10px;
            border-top: double 6px #ebebeb;
            background-color: #f7f7f7;
        }
        .content div.t
        {
            font-size: 13px;
            font-weight: bold;
            margin-bottom: 10px;
        }
        .desc
        {
            margin-left: 370px;
            overflow: hidden;
        }
        .desc ul
        {
            margin: 10px 0px;
        }
        .desc li
        {
            font-size: 14px;
            margin: 5px 0px;
            padding-bottom: 5px;
            border-bottom: 1px dotted #ccc;
        }
        .car
        {
            margin: 10px 0px;
            padding: 10px 0px;
            margin-left: 370px;
            text-align: center;
            background: #fffceb;
            border: solid 1px #eed97c;
        }
        .product_images
        {
            float: left;
            overflow: hidden;
            width: 370px;
        }
        .cover
        {
            cursor: pointer;
        }
        .cover img
        {
            margin: 10px auto;
            padding: 1px;
            border: 1px dotted #ccc;
        }
        /*----------------------------------------------*/
        .sameProduct
        {
            margin: 5px 0px;
            line-height: normal;
            overflow: hidden;
        }
        .sameProduct dt
        {
            width: 60px;
            padding: 7px 0;
            text-align: right;
            color: #b94708;
            float: left;
            overflow: hidden;
        }
        .sameProduct dd
        {
            overflow: hidden;
        }
        .sameProduct dd a
        {
            background-color: #ffffff;
            float: left;
            display: block;
            white-space: nowrap;
            padding: 5px;
            margin: 1px 0;
            margin-right: 5px;
            border: solid 1px #d7d7d7;
            cursor: pointer;
            text-decoration: none;
            color: #000000;
        }
        .sameProduct dd a.cur
        {
            border: solid 1px #ff8400;
            background-color: #ff8400;
            color: #fff;
        }
        .sameProduct dd a:hover
        {
            border: solid 1px #ff8400;
        }
    </style>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="jsContent" runat="server">
    <script type="text/javascript">
        $(function () {
            //可选属性选择
            $(".sameProduct a").click(function () { $(this).parent().find("a").removeClass("cur"); this.className = "cur"; });

            $("#divAlbum").ScrollImage({ // 图片
                image: { space: 106, shownum: 3 },
                onimageclick: function () {
                    var s = $(this);
                    $("div.cover").hide("normal", function () {
                        $("div.cover img").attr("src", s.attr("src"));
                        $("div.cover a").attr("href", s.attr("data-path")).attr("target", "_blank");
                    }).show("normal");
                }
            });

            $(":text[name='quantity']").blur(function () {
                var count = parseFloat($.trim(this.value));
                if (isNaN(count) || count < 1) {
                    alert("购买数量只能是整数且最小值不能小于1");
                    this.value = 1;
                }
            });
        });
    </script>
</asp:Content>
